import requests
import os
from time import sleep

class Brute:
        
        def __init__(self):
                self.login_url = "http://192.168.3.4"  
                self.logout_url = "http://172.16.1.253/F.htm" 

        def My_Requests(self,method,*args,**kwargs):
                try:
                        header = {
                                "User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.163 Safari/535.1",
                                "Connection":"close"
                        }
                        return requests.post(*args,**kwargs,headers = header) if method == "post" else requests.get(*args,**kwargs,headers=header)

                except Exception as e: 
                        print(e)
                        print("Something Wrong")
                        exit()
                        return False
                         
        def login(self,Account,Password):
                try:
                        data = {
                                "DDDDD":Account,
                                "upass":Password,
                                "0MKKey":"1"
                        }
                        #print(data)
                        response = self.My_Requests("post",self.login_url,data = data)
                        if response.status_code == 200:
                                if response.headers["Content-Length"] == "2501":
                                        return True
                        else:
                                return False
                        sleep(2)
                        #return True if self.My_Requests("post",s lf.login_url,data = data).headers["Content-Length"] == "2501" else False
                except KeyboardInterrupt:
                        exit()
        
        def logout(self):
            return self.My_Requests("get",self.logout_url)if True else False

